//package com.shopoo.oauth.infrastructure.factory;
//
//import org.springframework.beans.BeansException;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.stereotype.Component;
//
///**
// *
// * @Author <a href="mailto:android_li@sina.cn">MaoYuan.Li</a>
// * @Date 2022/3/19 4:48 PM
// */
//@Component
//public class BloomFilterFactory implements ApplicationContextAware {
//
//	private static ApplicationContext applicationContext;
//
//	@Override
//	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//		BloomFilterFactory.applicationContext = applicationContext;
//	}
//
//	public static <T> T getBean(Class<T> targetClz) {
//		T beanInstance = null;
//		//优先按type查
//		try {
//			beanInstance = (T)applicationContext.getBean(targetClz);
//		} catch (Exception e) {
//
//		}
//		//按name查
//		if (beanInstance == null) {
//			String simpleName = targetClz.getSimpleName();
//			//首字母小写
//			simpleName = Character.toLowerCase(simpleName.charAt(0)) + simpleName.substring(1);
//			beanInstance = (T)applicationContext.getBean(simpleName);
//		}
//		if (beanInstance == null) {
//			throw new RuntimeException("Component "+targetClz+" can not be found in spring container");
//		}
//		return beanInstance;
//	}
//}
